package com.darkteam.jhades.common.message;

import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;

public class ResponseMessage implements JHadesSerializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7555110106533515228L;

	private short function;

	private JHadesSerializable paran;
	
	
	public ResponseMessage() {
	}
	

	public ResponseMessage(short function) {
		super();
		this.function = function;
	}



	public ResponseMessage(short function, JHadesSerializable paran) {
		super();
		this.function = function;
		this.paran = paran;
	}

	public short getFunction() {
		return function;
	}

	public void setFunction(short function) {
		this.function = function;
	}

	public JHadesSerializable getParan() {
		return paran;
	}

	public void setParan(JHadesSerializable paran) {
		this.paran = paran;
	}

	@Override
	public ChannelBuffer toChannelBuffer() {
		ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
		buf.writeShort(function);
		if (paran !=null) {
			buf.writeBytes(paran.toChannelBuffer());
		}
		
		System.out.println("toChannelBuffer: " + ChannelBuffers.hexDump(buf));
		return buf;
	}
	
	@Override
	public String toString() {
		
		return super.toString()+ "[" + function + "]";
	}

}
